From: Jan Beulich Date: Wed, 7 Dec 2016 12:52:35 +0000 (+0100) Subject: libelf: section index 0 is special X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3258 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=41fe9cabf29ea15c1f8edee49326dfde705013d3;p=xen.git libelf: section index 0 is special When iterating over sections, table entry zero needs to be ignored. Signed-off-by: Jan Beulich Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Roger Pau Monné --- diff --git a/xen/common/libelf/libelf-dominfo.c b/xen/common/libelf/libelf-dominfo.c index 85c14da4e7..a52900c00c 100644 --- a/xen/common/libelf/libelf-dominfo.c +++ b/xen/common/libelf/libelf-dominfo.c @@ -536,7 +536,7 @@ elf_errorstatus elf_xen_parse(struct elf_binary *elf, if ( xen_elfnotes == 0 ) { count = elf_shdr_count(elf); - for ( i = 0; i < count; i++ ) + for ( i = 1; i < count; i++ ) { shdr = elf_shdr_by_index(elf, i); if ( !elf_access_ok(elf, ELF_HANDLE_PTRVAL(shdr), 1) ) diff --git a/xen/common/libelf/libelf-loader.c b/xen/common/libelf/libelf-loader.c index 4e12a715b6..c324f5ecc1 100644 --- a/xen/common/libelf/libelf-loader.c +++ b/xen/common/libelf/libelf-loader.c @@ -79,7 +79,7 @@ elf_errorstatus elf_init(struct elf_binary *elf, const char *image_input, size_t /* Find symbol table and symbol string table. */ count = elf_shdr_count(elf); - for ( i = 0; i < count; i++ ) + for ( i = 1; i < count; i++ ) { shdr = elf_shdr_by_index(elf, i); if ( !elf_access_ok(elf, ELF_HANDLE_PTRVAL(shdr), 1) ) diff --git a/xen/common/libelf/libelf-tools.c b/xen/common/libelf/libelf-tools.c index e73e729fff..0197b85819 100644 --- a/xen/common/libelf/libelf-tools.c +++ b/xen/common/libelf/libelf-tools.c @@ -153,7 +153,7 @@ ELF_HANDLE_DECL(elf_shdr) elf_shdr_by_name(struct elf_binary *elf, const char *n const char *sname; unsigned i; - for ( i = 0; i < count; i++ ) + for ( i = 1; i < count; i++ ) { shdr = elf_shdr_by_index(elf, i); if ( !elf_access_ok(elf, ELF_HANDLE_PTRVAL(shdr), 1) )